package com.lwj.kotlin.remotelibrary.ProxyTest;

import android.util.Log;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class DynamicEatProxys implements InvocationHandler {
    private Object object;

    public DynamicEatProxys(Object T) {
        object = T;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        wash();
        Object returnValue = method.invoke(object, args);//真正调用的方法，object是之前传进来的具体实例，args是接口所需要的方法参数
        return returnValue;
    }

    void wash() {
        Log.d("DynamicEatProxy", "Wash Hands");
    }
}
